home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
FROMUTS
/
ARCAUT
/
Automatons
/
Wire
< prev
Wrap
Text File
|
1991-07-27
|
3KB
|
81 lines
AUTOMATON*
Wire_World
This is a four state Moore neighbourhood automaton. It simulates the flow
of electrons around a circuit. Although it does not obey similar laws (such
as Kirchoff's) to real electrical current, memorys, clocks & logic gates
can all be built from basic components, thus a computer can be constructed
within the 'wire world' environment. The four states are background, wire,
electron head & electron tail. Background is inert; electron heads become
tails & tails become wire; wire will become electron head if it has one or
two electron head neighbours, otherwise it remains wire. This results in
electron head/tail pairs travelling in the direction of the head, along
stable wires, on an inert background. When executed, you are allowed to
design your own circuit, or load one in (press 'L'); disc space allowing,
two 128x128 screens are provided, called 'trans' & 'wheat'. Clicking select
draws wire from the current point to the pointer; adjust moves the current
point to the pointer & menu erases. The cursors place an electron at the
current point, while the cursors with right Ctrl place a 'diode' into the
circuit. When complete, press return to run the automaton.
INITIALISATION*
10DEF PROCdo
20*SetEval wrap on
30*SetEval eh 22
40*SetEval et 214
50*SetEval back 0
60*SetEval wire 137
70ENDPROC
SCREEN*
10DEF PROCdo
20LOCAL x%,y%,z%,c%,u%,v%,f$
30DIM buf% 256
40SYS "OS_ReadVarVal","wire",buf%,256:wire=!buf%
50SYS "OS_ReadVarVal","back",buf%,256:back=!buf%
60SYS "OS_ReadVarVal","eh",buf%,256:eh=!buf%
70SYS "OS_ReadVarVal","et",buf%,256:et=!buf%
80SYS "OS_ReadVarVal","sux",buf%,256:sux%=!buf%
90SYS "OS_ReadVarVal","suy",buf%,256:suy%=!buf%
100c%=FNacol(wire)
110PROCmouseon
120MOUSE TO 0,0:MOVE 0,0
130REPEAT MOUSE x%,y%,z%
140IF INKEY-87 PROCload:MOVE x%,y%
150CASE z% OF
160WHEN 4:c%=FNacol(wire):GCOL c% AND 63 TINT c%:DRAW x%,y%
170WHEN 2:c%=FNacol(back):GCOL c% AND 63 TINT c%:CIRCLE FILL x%,y%,12
180WHEN 1:MOVE x%,y%
190ENDCASE
200PROCcursors(u%,v%)
210IF u% OR v% THEN
220IF INKEY-8 THEN
230c%=FNacol(wire):GCOL c% AND 63 TINT c%
240DRAW BY -v%,u%:DRAW BY u%,v%:DRAW BY u%+v%,v%-u%
250DRAW BY v%-u%,-v%-u%:DRAW BY -u%,-v%:MOVE BY 2*u%-v%,2*v%+u%
260ELSE
270c%=FNacol(et):GCOL c% AND 63 TINT c%
280DRAW BY u%,v%
290c%=FNacol(eh):GCOL c% AND 63 TINT c%
300PLOT 9,u%,v%
310ENDIF
320REPEAT PROCcursors(u%,v%):UNTIL (u% OR v%)=0
330ENDIF
340UNTIL INKEY-74
350MOUSE OFF
360ENDPROC
CODE*
( CELL <back> = IF (<back> ==)
CELL <eh> = IF ( <et> ==)
CELL <et> = IF (<wire> ==)
READ_NEIG
<eh> SCOUNT_NEIG DUP 1 = IF ( <eh> ==)
2 = IF ( <eh> ==)
<wire> == )
END*